# @Time : 2021/6/18 8:50 

# @Author : zhujianhao

# @File : airtest_demo.py 

# @Software: PyCharm

from airtest.core.api import *
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pytest
from airtest_selenium.proxy import WebChrome
# Select类需要引入
from selenium.webdriver.support.select import Select
def test():
    driver = WebChrome('D:\PycharmProjects\python_web_framework\Common\driver\chromedriver.exe')
    driver.maximize_window()
    driver.implicitly_wait(20)
    driver.get("https://www.baidu.com/gaoji/preferences.html")
    # 定位下拉框元素
    ime_select = driver.find_element_by_id('ime')
    # 实例下拉框
    select = Select(ime_select)

    select.select_by_index(0)
    print('1.此时下拉框选中选项的值为：',ime_select.get_attribute('value'))

    select.select_by_value('2')
    print('2.此时下拉框选中选项的值为：',ime_select.get_attribute('value'))

    select.select_by_visible_text('关闭')
    print('3.此时下拉框选中选项的值为：',ime_select.get_attribute('value'))
    assert 1==1
    driver.quit()



